package com.zhi.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import com.zhi.dao.DictionaryRepository;
import com.zhi.entity.Dictionary;
import com.zhi.service.DictionaryService;

@Service
public class DictionaryServiceImpl implements DictionaryService {

	@Autowired
	private DictionaryRepository dictionaryRepository;
	
	@Override
	public List<Dictionary> getEntityList() {
		return dictionaryRepository.findAll();
	}
	
	@Override
	public Page<Dictionary> getEntityList(Pageable pageable) {
		return dictionaryRepository.findAll(pageable);
	}

	@Override
	public List<Dictionary> getDictsByCodeType(String codeType) {
		return dictionaryRepository.getDictsByCodeType(codeType);
	}

	@Override
	public Dictionary getOne(Integer id) {
		return dictionaryRepository.getOne(id);
	}

	@Override
	public List<Dictionary> findByCodeTypeAndCode(String codeType,String code){
		return dictionaryRepository.findByCodeTypeAndCode(codeType,code);
	}

	@Override
	public void save(Dictionary dictionary) {
		dictionaryRepository.save(dictionary);
	}

	@Override
	public void edit(Dictionary dictionary) {
		dictionaryRepository.save(dictionary);
	}

	@Override
	public void delete(Integer id) {
		dictionaryRepository.deleteById(id);
	}

	@Override
	public Integer count() {
		return (int) dictionaryRepository.count();
	}

}
